
package com.insigma.business.qrcode.common.converter;


import com.insigma.business.qrcode.job.dto.JobFairDTO;
import com.insigma.business.qrcode.job.dto.request.JobFairInsertRequest;
import com.insigma.business.qrcode.job.dto.request.JobFairSearchRequest;
import com.insigma.business.qrcode.job.dto.request.JobFairUpdateRequest;
import com.insigma.business.qrcode.job.dto.search.JobFairBSearcher;
import com.insigma.business.qrcode.job.entity.JobFairDO;
import org.springframework.beans.BeanUtils;

import java.util.List;


public class JobFairProviderConverter extends AbstractConverter<JobFairDTO, JobFairDO> {

    private final static JobFairProviderConverter jobFairConverter = new JobFairProviderConverter();

    private JobFairProviderConverter(){}

    
    public static JobFairBSearcher convertRequestSO2Searcher(final JobFairSearchRequest request){
        final JobFairBSearcher jobFairBSearcher = new JobFairBSearcher(request.getPageNo(),
        request.getPageSize(),request.getSortKeyValueJoint());
        BeanUtils.copyProperties(request,jobFairBSearcher);
        return jobFairBSearcher;
    }

    
    public static JobFairDO convertRequestUO2DO(final JobFairUpdateRequest jobFairUpdateRequest) {
        final JobFairDO jobFairDO = new JobFairDO();
        BeanUtils.copyProperties(jobFairUpdateRequest,jobFairDO);
        
        return jobFairDO;
    }

    
    public static JobFairDO convertRequestIO2DO(final JobFairInsertRequest jobFairInsertRequest) {
        final JobFairDO jobFairDO = new JobFairDO();
        BeanUtils.copyProperties(jobFairInsertRequest,jobFairDO);
        return jobFairDO;
    }

    
    public static List<JobFairDTO> convertResponseDOList2DTOList(final List<JobFairDO> jobFairDOList){
        return jobFairConverter.convertGenericResponseDOList2DTOList(jobFairDOList);
    }

    
    public static JobFairDTO convertResponseDO2DTO(final JobFairDO jobFairDO){
        return jobFairConverter.convertGenericResponseDO2DTO(jobFairDO);
    }

    
    @Override
    protected JobFairDTO doConvertResponseDO2DTO(JobFairDO jobFairDO) {
        final JobFairDTO jobFairDTO = new JobFairDTO();
        try {
            BeanUtils.copyProperties(jobFairDO, jobFairDTO);
        }catch(RuntimeException be){
            
            return null;
        }
        return jobFairDTO;
    }

}
